package com.lk.pet.customers.repository;

import com.lk.pet.customers.model.Pet;
import com.lk.pet.customers.model.PetType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Optional;

public interface PetRepository extends JpaRepository<Pet,Integer> {

    @Query("SELECT ptype FROM PetType ptype ORDER BY ptype.name")
    List<PetType> findPetTypes();

    @Query("FROM PetType ptype where ptype.id = :typeId")
    Optional<PetType> findPetTypeById(@Param("typeId") int typeId);
}
